<?php

class Model_DbTable_Onlineordermonitor extends Zend_Db_Table_Abstract {
	
	protected $_name = 'online_order_monitor';
	
	
	public function listAllOrders(){
		
		$rows = $this->fetchAll('1','id_order');
		return $rows;
	}
	
	
	public function addOrder($idOrder,$shop,$date,$currentHour,$status){
		$data = array(
				"id_order" => $idOrder,
				"shop" => $shop,
				"date" => $date,
				"hour" => $currentHour,
				"status" => $status
		);
		$this->insert($data);
	}
	
	public function updatStatus($idOrder,$status){
		date_default_timezone_set("Australia/Melbourne");
		$data = array(
				"status" => $status,
				"update_date" => Model_DatetimeHelper::dateToday(),
				"update_hour" => date("H")
				);
		$this->update($data,"`id_order` = ".$idOrder);
	}
	
	public function removeOrder($idOrder){
		
		$this->delete("`id_order` = ".$idOrder);
	}
	public function getOrder($idOrder){
		
		$row = $this->fetchRow("`id_order` = ". $idOrder);
		if(!$row) return false;
		return $row->toArray();
		
	}
	public function getOrderByShop($shop){
		$rows = $this->fetchAll("`shop` LIKE '".$shop."'","id_order");
		$rows = $rows->toArray();
		if(empty($rows)) return false;
		return $rows;
	}
	 

}

?>